//package com.slofzx.nuoda.evaluation.project.enums;
//
//import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
//import com.fasterxml.jackson.annotation.JsonFormat;
//import com.slofzx.nuoda.common.EnumConfig;
//import com.slofzx.nuoda.common.config.Type;
//import com.slofzx.nuoda.common.enums.DataFormatEnum;
//import com.slofzx.nuoda.common.util.DataConvertUtil;
//import com.slofzx.nuoda.custom.field.enums.UnitTypeEnum;
//import com.slofzx.nuoda.evaluation.project.dto.ProjectReportDetailYearDTO;
////import com.slofzx.nuoda.evaluation.project.service.impl.ModelExportRefServiceImpl;
//import com.slofzx.nuoda.evaluation.project.util.DoubleUtil;
//import com.slofzx.nuoda.evaluation.project.vo.CommonExportDataVO;
//import com.slofzx.nuoda.evaluation.project.vo.ProjectInfoVO;
//import com.slofzx.nuoda.evaluation.project.vo.ProjectReportDetailYearVO;
//import com.slofzx.nuoda.evaluation.project.vo.ProjectYearDataVO;
//import com.slofzx.nuoda.evaluation.ref.enums.ModelExportItem;
//import org.apache.commons.collections4.MapUtils;
//
//import java.util.List;
//import java.util.Map;
//
///**
// * 评价计算后需要导出的数据项
// *
// * @author sunfuyong
// */
//@JsonFormat(shape = JsonFormat.Shape.OBJECT)
//@EnumConfig(id = "project-report-item", name = "项目简报数据项", valueFormat = DataFormatEnum.JSON)
//public enum ProjectReportItemEnum implements ExcelExportItem {
//    ECONOMIC_LIMIT_YEAR("economic_limit_year","评价截止年",false,false),
//
//    IRR_BEFORE_TAX("irr_before_tax", "税前内部收益率", UnitTypeEnum.PERCENT,false),
//    IRR_AFTER_TAX("irr_after_tax", "税后内部收益率",false),
//    PBP_BEFORE_TAX("pbp_before_tax", "税前投资回收期", UnitTypeEnum.PERCENT,false),
//
//    PBP_AFTER_TAX("pbp_after_tax", "税后投资回收期",false),
//    NPV_BEFORE_TAX("npv_before_tax", "税前财务净现值", UnitTypeEnum.PERCENT,false),
//    NPV_AFTER_TAX("npv_after_tax", "税后财务净现值",false),
//    NET_PROFIT_AFTER_TAX("net_profit_after_tax", "税后净利润",false),
//    NET_PROFIT_AFTER_TAX_YEAR("net_profit_after_tax_year", "税后净利润(年份相关)",true),
//    TOTAL_NET_PROFIT_YEAR("total_net_profit_year", "利润总额(年份相关)",true),
//    CASH_FLOW_AFTER_TAX("cash_flow_after_tax", "税后现金流(年份相关)",true),
////    NEW_WATER_WELL_COUNT("new_water_well_count", "新钻水井") {
////        @Override
////        public void updateDataMap(ProjectReportDetailYearDTO dataDTO,Double value) {
////            dataDTO.setWaterWellCount(value);
////        }
////    },
//    /**
//     * 总投资。总投资不一定等于钻井+采油+地面投资，可研中还包括方案编制费等
//     */
//    TOTAL_INVEST("total_invest", "总投资"),
//    INVEST_WELL_DRILL("invest_well_drill", "钻井投资"),
//    INVEST_GROUND("invest_ground", "地面投资"),
//    INVEST_PRODUCT_EXTRACT("invest_product_extract", "采油(气)投资"),
//    M_TON_CAPACITY_DEVELOP_INVEST("m_ton_capacity_develop_invest", "百万吨产能开发投资"),
//    B_M3_CAPACITY_DEVELOP_INVEST("b_m3_capacity_develop_invest", "十亿方产能开发投资"),
//    TOTAL_OIL_OUTPUT_EVA_PERIOD("total_oil_output_eva_period", "评价期内累计产油量"),
//
//
//    BALANCE_PRICE("balance_price_yuan", "基准平衡油价(人民币/吨)",UnitTypeEnum.YUAN_PER_TON,false,true),
//    BALANCE_TOTAL_OUTPUT("balance_total_output", "基准平衡累产量",UnitTypeEnum.TON,false,true),
//    TOTAL_COST("total_cost", "总成本"),
//    TOTAL_MARKETABLE("total_marketable", "总商品量"),
//    UNIT_DEVELOP_COST("unit_develop_cost", "单位开发成本"),
//    UNIT_TOTAL_COST("unit_total_cost", "单位总成本合计"),
//    UNIT_TOTAL_COST_YEAR("unit_total_cost_year", "年度单位总成本"),
//    TOTAL_OPERATE_COST("total_operate_cost", "总操作成本(年份相关)", UnitTypeEnum.TEN_THOUSAND_YUAN, true) {
//
//        @Override
//        public void updateDataMap(Map<String, Object> dataMap, List<CommonExportDataVO> dataList, List<Integer> yearList) {
//            // dataDTO.setTotalCost(value);
//            if (CollectionUtils.isEmpty(dataList)) {
//                return;
//            }
//            Double sum = 0D;
//
//            for (Integer year : yearList) {
//                Double yearSum = 0D;
//                for (CommonExportDataVO dataVO : dataList) {
//                    final Map<Integer, ProjectReportDetailYearVO> detailYearVOMap = dataVO.getProjectReportDetailYearVOMap();
//                    if (MapUtils.isEmpty(detailYearVOMap)) {
//                        return;
//                    }
//                    final Integer projectYear = dataVO.getProjectInfoVO().getYear();
//
//                    final ProjectReportDetailYearVO detailYearVO = detailYearVOMap.get(projectYear + year - 1);
//                    if (detailYearVO == null) {
//                        continue;
//                    }
//                    // 多个对象相同年份的数据累加
//                    yearSum += DataConvertUtil.parse2Double(detailYearVO.getTotalOperateCost());
//                }
//                // 年份数据组装为 key => id:年份 total_operate_cost:1 value=>value
//                dataMap.put(TOTAL_OPERATE_COST.getId() + ":" + year, yearSum);
//                sum += yearSum;
//
//            }
//            dataMap.put(TOTAL_OPERATE_COST.getId() + ":sum", sum);
//        }
//    },
//    OIL_OUTPUT_YEAR("oil_output_year", "原油年产量(年份相关)", UnitTypeEnum.TON, true) {
//
//        @Override
//        public void updateDataMap(Map<String, Object> dataMap, List<CommonExportDataVO> dataList, List<Integer> yearList) {
//            if (CollectionUtils.isEmpty(dataList)) {
//                return;
//            }
//            Double sum = 0D;
//            for (Integer year : yearList) {
//                Double yearSum = 0D;
//                for (CommonExportDataVO dataVO : dataList) {
////                final List<ProjectYearDataVO> projectYearDataVOS = dataVO.getProjectYearDataVOS();
//                    final Map<Integer, ProjectYearDataVO> yearDataVOMap = dataVO.getProjectYearDataVOMap();
//
//                    if (MapUtils.isEmpty(yearDataVOMap)) {
//                        return;
//                    }
//                    final ProjectYearDataVO projectYearDataVO = yearDataVOMap.get(year);
//                    if (projectYearDataVO == null) {
//                        continue;
//                    }
//                    yearSum += DataConvertUtil.parse2Double(projectYearDataVO.getOilOutput());
//                }
//                // 年份数据组装为 key => id:年份 oil_output_year:1 value=>value
//                dataMap.put(OIL_OUTPUT_YEAR.getId() + ":" + year, yearSum);
//                sum+=yearSum;
//            }
//            dataMap.put(OIL_OUTPUT_YEAR.getId() + ":sum", sum);
//        }
//    },
//    SUM_OIL_OUTPUT("sum_oil_output", "累积产量", UnitTypeEnum.TEN_THOUSAND_TON) {
//
//        @Override
//        public void updateDataMap(Map<String, Object> dataMap, List<CommonExportDataVO> dataList, List<Integer> yearList) {
//            final String key = OIL_OUTPUT_YEAR.getId() + ":sum";
//            final Double value = compute(DataConvertUtil.parse2Double(dataMap.get(key)), 10000D, null);
//            dataMap.put(SUM_OIL_OUTPUT.getId(), value);
//        }
//    },
//    SUM_INVEST("sum_invest", "投资合计", UnitTypeEnum.TEN_THOUSAND_YUAN) {
//
//        @Override
//        public void updateDataMap(Map<String, Object> dataMap, List<CommonExportDataVO> dataList, List<Integer> yearList) {
//            if (CollectionUtils.isEmpty(dataList)) {
//                return;
//            }
//            Double sum = 0D;
//            for (CommonExportDataVO dataVO : dataList) {
//                final Map<Integer, ProjectYearDataVO> projectYearDataVOMap = dataVO.getProjectYearDataVOMap();
//                if (MapUtils.isEmpty(projectYearDataVOMap)) {
//                    continue;
//                }
//
//                for (ProjectYearDataVO yearDataVO : projectYearDataVOMap.values()) {
//                    if (yearDataVO == null) {
//                        continue;
//                    }
//                    sum += DataConvertUtil.parse2Double(yearDataVO.getSumInvest());
//                }
//            }
//            dataMap.put(getId(), sum);
//        }
//    },
//    DRILL_EXTRACT_INVEST("drill_extract_invest", "钻采投资", UnitTypeEnum.TEN_THOUSAND_YUAN,false) {
//
//        @Override
//        public void updateDataMap(Map<String, Object> dataMap, List<CommonExportDataVO> dataList, List<Integer> yearList) {
//            if (CollectionUtils.isEmpty(dataList)) {
//                return;
//            }
//            Double sum = 0D;
//            for (CommonExportDataVO dataVO : dataList) {
//                final Map<Integer, ProjectYearDataVO> projectYearDataVOMap = dataVO.getProjectYearDataVOMap();
//                if (MapUtils.isEmpty(projectYearDataVOMap)) {
//                    continue;
//                }
//
//                for (ProjectYearDataVO yearDataVO : projectYearDataVOMap.values()) {
//                    if (yearDataVO == null) {
//                        continue;
//                    }
//                    sum += DataConvertUtil.parse2Double(yearDataVO.getDrillExtractInvest());
//                }
//            }
//            dataMap.put(getId(), sum);
//        }
//    },
//    GROUND_INVEST("ground_invest", "地面投资", UnitTypeEnum.TEN_THOUSAND_YUAN,false) {
//
//        @Override
//        public void updateDataMap(Map<String, Object> dataMap, List<CommonExportDataVO> dataList, List<Integer> yearList) {
//            if (CollectionUtils.isEmpty(dataList)) {
//                return;
//            }
//            Double sum = 0D;
//            for (CommonExportDataVO dataVO : dataList) {
//                final Map<Integer, ProjectYearDataVO> projectYearDataVOMap = dataVO.getProjectYearDataVOMap();
//                if (MapUtils.isEmpty(projectYearDataVOMap)) {
//                    continue;
//                }
//
//                for (ProjectYearDataVO yearDataVO : projectYearDataVOMap.values()) {
//                    if (yearDataVO == null) {
//                        continue;
//                    }
//                    sum += DataConvertUtil.parse2Double(yearDataVO.getDrillExtractInvest());
//                }
//            }
//            dataMap.put(GROUND_INVEST.getId(), sum);
//        }
//    },
//    ;
//
//    /**
//     * 数据类型id
//     */
//    private String id;
//    /**
//     * 数据类型展示名称
//     */
//    private String name;
//
//    /**
//     * 单位
//     */
//    private Type unit;
//
//    /**
//     * 是否年份相关
//     */
//    private boolean yearRelated;
//
//    /**
//     * 平衡性分析结果
//     */
//    private boolean balanceResult;
//
//    ProjectReportItemEnum(String id, String name) {
//        this.id = id;
//        this.name = name;
////        ModelExportRefServiceImpl.registerModelExportItem(this);
//    }
//
//    ProjectReportItemEnum(String id, String name, boolean yearRelated) {
//        this(id,name);
//        this.yearRelated = yearRelated;
//    }
//
//    ProjectReportItemEnum(String id, String name, Type unit) {
//        this(id,name);
//        this.unit = unit;
//    }
//
//    ProjectReportItemEnum(String id, String name, Type unit, boolean yearRelated) {
//        this(id,name,unit);
//        this.yearRelated = yearRelated;
//    }
//    ProjectReportItemEnum(String id, String name, Type unit, boolean yearRelated, boolean balanceResult) {
//        this(id,name,unit,yearRelated);
//        this.balanceResult = balanceResult;
//    }
//    ProjectReportItemEnum(String id, String name, boolean yearRelated, boolean balanceResult) {
//        this(id,name);
//        this.balanceResult = balanceResult;
//        this.yearRelated = yearRelated;
//    }
//
//    @Override
//    public String getId() {
//        return id;
//    }
//
//    @Override
//    public String getName() {
//        return name;
//    }
//
//    public String getDataType() {
//        return "number";
//    }
//
//    public boolean isBalanceResult() {
//        return balanceResult;
//    }
//
//    /**
//     * 除法计算
//     *
//     * @param val1
//     * @param val2
//     * @param val3
//     * @return
//     */
//    private static Double compute(Double val1, Double val2, Double val3) {
//        Double div = 0D;
//        if (val1 == null) {
//            val1 = 0D;
//        }
//        if (val2 != null && val2 != 0) {
//            div = val1 / val2;
//            if (val3 != null && val3 != 0) {
//                div = div / val3;
//            }
//        }
//        return DoubleUtil.getScale(div, 2);
//    }
//
//
//    public void updateDataMap(Map<String, Object> dataMap, List<CommonExportDataVO> dataList, List<Integer> yearList) {
//
//    }
////    /**
////     * 根据id获取对应的枚举
////     *
////     * @param id 枚举值的标识
////     * @return
////     */
////    public static ProjectReportItemEnum getEnum(String id) {
////        for (ProjectReportItemEnum dataTypeEnum : ProjectReportItemEnum.values()) {
////            if (dataTypeEnum.getId().equals(id)) {
////                return dataTypeEnum;
////            }
////        }
////        return null;
////    }
//
//    public String getUnit() {
//        if (unit == null) {
//            return null;
//        }
//        return unit.getId();
//    }
//
//    @Override
//    public boolean isYearRelated() {
//        return yearRelated;
//    }
//
//}
